<?php
define('ACC', true);
require('../include/init.php');

$act=isset($_GET['act'])?$_GET['act']:'buy';
$cart=CartTool::getCart();
$goods=new goods_Model();
if ($act='buy'){
    $goods_id=isset($_GET['goods_id'])?$_GET['goods_id']+0:0;
    $num=isset($_GET['num'])?$_GET['num']+0:1;
    if ($goods_id){
        $g=$goods->find($goods_id);
        if (!empty($g)){
            if ($g['is_delete'] == 1 || $g['is_onsale'] == 0){
                $msg='此商品不能购买';
                include (ROOT.'view/front/error.html');
                exit;
            }
            $cart->addItem($goods_id,$g['goods_name'],$g['shop_price'],$num);
        }
    }
    $allitems=$cart->all();
    $allitems=$goods->getCartGoods($allitems);
    include (ROOT.'view/front/flow.html');
}

